Revert "label: Never measure more than max-width-chars"
authorBenjamin Otte <otte@redhat.com>
Thu, 4 Nov 2021 12:28:45 +0000 (13:28 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 5 Nov 2021 05:12:33 +0000 (06:12 +0100)
This reverts commit ba44e7a228534ff066694ad97d25eaa23ec5f3af.

The change was meant to revert to old GTK3 behavior but it actually
broke new GTK4 behavior that is in use where max-width-chars is used to
determine an ideal size, but where we don't want to limit the width to
that size.

So what happens is the reintroduction of GTK3-style lots of whitepsace
bugs, and we really don't want those.

We also don't want to break backwards compat if we can avoid it.

So let's revert this.

The reftest that was made for this purpose has been adapted.

Fixes #4399

gtk/gtklabel.c
testsuite/reftests/label-max-width-chars-and-halign-and-infinite-width.ref.ui

index 661902a27571a194a2b23c3285c69bb49a9c2fae..b9886dd4717a4fbc8ff24b6bab814e71e76df423 100644 (file)
@@ -1045,20 +1045,7 @@ get_height_for_width (GtkLabel *self,
   PangoLayout *layout;
   int text_height, baseline;
 
-  width *= PANGO_SCALE;
-  if (self->max_width_chars > -1)
-    {
-      int char_pixels, width_chars;
-
-      layout = gtk_label_get_measuring_layout (self, NULL, -1);
-      char_pixels = get_char_pixels (GTK_WIDGET (self), layout);
-      if (self->width_chars > self->max_width_chars)
-        width_chars = self->width_chars;
-      else
-        width_chars = self->max_width_chars;
-      width = MIN (char_pixels * width_chars, width);
-    }
-  layout = gtk_label_get_measuring_layout (self, NULL, width);
+  layout = gtk_label_get_measuring_layout (self, NULL, width * PANGO_SCALE);
 
   pango_layout_get_pixel_size (layout, NULL, &text_height);
 
index 68c5d0a1125d506acf5b7c1bb8d03250524abf8e..d3f075290b048b82fd0ba380b45445e8cc85c0fe 100644 (file)
@@ -8,9 +8,7 @@
         <property name="halign">start</property>
         <property name="valign">end</property>
         <property name="xalign">0</property>
-        <property name="label" translatable="yes">ABCDE
-ABCD</property>
-        <property name="max_width_chars">4</property>
+        <property name="label" translatable="yes">ABCDE ABCD</property>
         <attributes>
           <attribute name="font-desc" value="Monospace"></attribute>
         </attributes>